package cn.vastbase.jdbc.util;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Properties;

public class JdbcUtils {

    private static boolean initialized = false;

    private static Connection connection(Properties props, String url) throws Exception {
        initDriver();
        return DriverManager.getConnection(url, props);
    }

    public static void closeDB(Connection con) throws SQLException {
        if (con != null) {
            con.close();
        }
    }

    public static void initDriver() throws Exception {
        synchronized (JdbcUtils.class) {
            if (initialized) {
                return;
            }
            initialized = true;
        }
    }
}
